﻿using System;

namespace YawetagLib.Facade
{
    public static class FacadeFactoryBuilder
    {
        public static void RegisterProvider(Type providerType)
        {
            ProviderType = providerType;
        }

        private static IFacadeProvider GetProvider()
        {
            return (IFacadeProvider)Activator.CreateInstance(ProviderType);
        }

        public static IFacadeFactory GetFactory()
        {
            return ProviderType != null ? GetProvider().GetFactory() : new DefaultFacadeFactory();
        }

        public static void Dispose()
        {
            GetFactory().Dispose();
        }

        private static Type ProviderType { get; set; }
    }
}
